<?php require_once(dirname(__FILE__).'/../func/func_db.php'); ?>

<?php
	$do = $_GET['do'];
	$blogname = db_options('blogname');
	$arrDo = array('1'=>'文章管理', '2'=>'评论管理', '3'=>'用户管理', '4'=>'切换主题', '5'=>'暂停/启动');
?>
<?php include dirname(__FILE__).'/admin_pages/login_check.php'; //check login information. ?>

<?php if(('chk' != $do) && ('login' != $do)): ?>
<wml>
  <?php if(empty($do)): //"Control Panel" index page. ?>
  <card title="<?php echo '控制面板 - '.$blogname; ?>">
		<p><a href="<?php echo './admin.php'.'?user='.$username.'&pwd='.$userpwd; ?>"><?php echo $blogname; ?></a>	<?php get_user_role($user->ID); ?></p>
		<p><small>当前用户：<?php echo $user->display_name; ?></small></p>
		<?php foreach($arrDo as $key => $eachDo): ?>
		<p><a href="<?php echo './admin.php'.'?do='.$key.'&user='.$username.'&pwd='.$userpwd; ?>"><?php echo $eachDo; ?></a></p>
		<?php endforeach; ?>
  </card>
	<?php else: ?>
  <card title="<?php echo $arrDo[$do].' - '.$blogname; ?>">
  <?php
  	$admin_page = dirname(__FILE__).'/admin_pages/'.$do.'.php';
  	if(file_exists($admin_page)){
	  	include $admin_page;
  	}else{
  		//echo 'Would you forget to put the admin_page in the right place?';
  	}
  ?>
  </card>
	<?php endif; ?>
</wml>
<?php endif; ?>
